/**
 * 
 */
package com.cms.serviceImpl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cms.constant.CmsConstant;
import com.cms.pojo.Article;
import com.cms.pojo.Category;
import com.cms.pojo.Channel;
import com.cms.pojo.vo.ArticleVo;
import com.cms.service.ArticleService;
import com.cms.show.mapper.ArticleMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

/**
 * @author zhaoyan
 *
 * 2020年1月9日
 */
@Service
public class ArticleServiceImpl implements ArticleService{

	@Autowired
	private ArticleMapper articleMapper; 
	
	
	@Override
	public PageInfo<Article> findArticle(ArticleVo articleVo, Integer pageNum) {
		// TODO Auto-generated method stub
		PageHelper.startPage(pageNum, CmsConstant.SIZE);
		return new PageInfo<Article>(articleMapper.findArticle(articleVo));
	}


	@Override
	public Article getArticle(Integer articleId) {
		// TODO Auto-generated method stub
		return articleMapper.getArticle(articleId);
	}


	@Override
	public Integer checkArticle(Integer id, Integer status) {
		// TODO Auto-generated method stub
		return articleMapper.checkArticle(id,status);
	}


	@Override
	public Integer setHot(Integer id, Integer hot) {
		// TODO Auto-generated method stub
		return articleMapper.setHot(id ,hot);
	}


	@Override
	public List<Channel> showChannel() {
		// TODO Auto-generated method stub
		return articleMapper.findChannel();
	}


	@Override
	public List<Category> findCategoryById(Integer channelID) {
		// TODO Auto-generated method stub
		return articleMapper.findCategory(channelID);
	}


	@Override
	public int addArticle(Article article) {
		// TODO Auto-generated method stub
		return articleMapper.addarticle(article);
	}


	@Override
	public PageInfo<Article> findArticleByUid(Integer id, Integer pageNum) {
		// TODO Auto-generated method stub
		PageHelper.startPage(pageNum, 5);
		
		return new PageInfo<Article>(articleMapper.findArticleByUid(id));
	}


	@Override
	public Integer delArticleById(Integer id) {
		// TODO Auto-generated method stub
		return articleMapper.delArticleById(id);
	}
	
	
	
	
}
